﻿using System;
using System.Threading;

namespace NClass.TestHelper
{
	public static class Timer
	{
		public static void TimedExecution(int milliseconds, Action executeMethod)
		{
			var workerThread = new Thread(() => { executeMethod(); });

			workerThread.Start();

			bool finished = workerThread.Join(TimeSpan.FromMilliseconds(milliseconds));
			if (!finished)
			{
				workerThread.Abort();
			}
		}
	}
}
